<%--
  Created by IntelliJ IDEA.
  User: hz
  Date: 2024/7/23
  Time: 10:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>我的评论</title>
  <!-- 引入 layui.css -->
  <link rel="stylesheet" href="/layui-v2.9.0/layui/css/layui.css" media="all">
  <script src="/layui-v2.9.0/layui/layui.js"></script>
  <style>
    #header{
      position: fixed;
      top: 0;
      left: 0;
      z-index: 10;


    }
    #sidebar{
      display: flex;
      flex-direction: column;
      position: fixed;
      top: 50px; /* 留出头部导航的高度 */
      bottom: 0;
      left: 0;
      width: 200px;
      height: 100%;
      padding: 10px;
      margin-top: 30px;
      z-index: 10 ;
    }
    #content {

      margin-top: 100px;
      width:51%;
      border: 1px solid gold;

    }
    #content_head_container{
      display: inline-list-item;
    }
    #sidebar_right{
      display: flex;
      flex-direction: column;
      position: fixed;
      top: 50px; /* 留出头部导航的高度 */
      bottom: 0;
      left: 0;
      width: 300px;
      height: 100%;
      padding: 10px;
      margin-top: 30px;
      margin-left: 1100px;
      z-index: 10 ;
      border: 1px solid saddlebrown;
    }
    #userHead{
      border-radius: 50%;
      overflow: hidden;
      width: 15%;
      height: 15%;
    }
    .container {
      display: flex;
      justify-content: flex-start;
      align-items: center;
      z-index: 10;
      border: none;
      /*padding: 10px;*/

    }
    .layui-nav *{
      font-size: 20px;
    }
    .layui-nav-tree.layui-nav-side{
      position: relative;
      margin-top: 10px;
    }
  </style>
</head>
<body>
<!--水平导航-->
<div id="header" class="layui-form layui-col-xs12 layui-bg-gray">
  <div class="container layui-header">
    <ul class="layui-nav layui-layout-left  layui-bg-gray" >
      <!-- 移动端显示 -->
      <li class="layui-nav-item layui-hide-xs">
        <img style="width: 40px;height: 40px; padding: 10px" src="/img/热趣部落.png" alt="图片">
      </li>
      <li class="layui-nav-item layui-hide-xs">
        <input type="text" placeholder="" class="layui-input">
        <div class="layui-input-split" style="cursor: pointer;">
          <i class="layui-icon layui-icon-search"></i>
        </div>

      </li>
      <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
        <i class="layui-icon layui-icon-spread-left"></i>
      </li>
      <li class="layui-nav-item "><a href="/forward/indexPage">首页</a></li>
      <li class="layui-nav-item "><a href="/forward/forwardUserIndexPage">个人中心</a></li>
      <li class="layui-nav-item "><a href="/forward/forwardUserSettingPage">账号设置</a></li>
      </li>
    </ul>
  </div>
</div>
<!--垂直导航-->
<div id="sidebar" class="layui-col-xs3 layui-col-xs-offset1">
  <ul  class="layui-nav layui-nav-tree layui-nav-side layui-bg-gray">
        <span class="layui-nav-item" style="padding-left: 10px">
             个人主页
        </span>
    <li class="layui-nav-item">
      <a  href="/forward/forwardUserIndexPage">
        <i class="layui-icon layui-icon-home">我的主页</i>
      </a>
    </li>
    <li class="layui-nav-item">
      <a href="/forward/forwardUserSubPage">
        <i class="layui-icon layui-icon-user">  我的关注</i>
      </a>
    </li>
    <li class="layui-nav-item">
      <a href="/forward/forwardUserTagPage">
        <i class="layui-icon layui-icon-face-smile-b">  我的兴趣</i>
      </a>
    </li>
    <%--        <li class="layui-nav-item">--%>
    <%--            <a href="interstTribal.html">--%>
    <%--                <i class="layui-icon layui-icon-group">兴趣部落 </i>--%>
    <%--            </a>--%>
    <%--        </li>--%>
    <li class="layui-nav-item">
      <a href="/forward/forwardUserFriendPage"> <i class="layui-icon layui-icon-friends"> 我的好友 </i></a>
    </li>
    <li class="layui-nav-item">
      <a href="/forward/forwardUserCommentPage"> <i class="layui-icon layui-icon-log">  我的评论</i></a>
    </li>
  </ul>
</div>
<!--内容展览-->
<div id="content" class="layui-col-xs-offset3">
  <div class="layui-bg-gray" style="padding: 16px;">
    <div id="card" class="layui-card">
      <div class="layui-input-inline layui-input-wrap">
        <div class="layui-card-header layui-input-inline">
          <div class="layui-input-inline">
            <p>我的评论</p>
          </div>
          <div class="layui-input-inline" style="margin-right: 20px;!important;"      >
            <div class="layui-input-prefix">
              <i class="layui-icon layui-icon-search"></i>
            </div>
            <input style="margin-right: 20px" type="text" class="layui-input " placeholder="搜索框" >
          </div>
        </div>


      </div>
      <!--           评论填充-->
      <div class="layui-card-body" style="margin-top: 20px">
        <table class="layui-hide" id="ID-table-demo-setRowChecked"  lay-filter="deletePost"></table>

        <!--定义操作空间栏-->
        <script type="text/html" id="templet-demo-theads-tool">
          <div class="layui-clear-space">
            <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="delete">删除</a>
          </div>
        </script>

      </div>
    </div>
  </div>
</div>

<script>
  layui.use(function(){
    var layer = layui.layer;
    var table = layui.table;
    var $ = layui.$;
    table.render({
      elem: '#ID-table-demo-setRowChecked',
      id: 'ID-table-demo',
      url: '/post/getPostByPageUid', // 此处为静态模拟数据，实际使用时需换成真实接口
      page: true,
      cols: [[
        {
          fixed: 'left',
          title: '操作',
          toolbar: '#templet-demo-theads-tool',
          width: '10%',
          align: 'center'
        },
        {field: 'pid', title: 'ID', width: '5%', fixed: 'left', unresize: true, sort: true},
        {
          field: 'user.uname', title: '发表用户',
          templet: function (d) {
            return d.user ? d.user.uname : 'null';
          },
          width: '15%'
        },
        {field: 'ptime', title: '发表时间', width: '10%'},
        {field: 'ptitle', title: '标题', width: '15%'},
        {field: 'ptext', title: '内容', width: '25%'},
        {field: 'purl', title: '图片', width: '10%'},
        {field: 'pthumbs', title: '点赞数', width: '9%', sort: true},
        {field: 'preplys', title: '回复数', width: '9%', sort: true},
      ]],
      initSort: { // 设置初始排序
        field: 'pid', // 字段名
        type: 'desc' // 倒序
      },
      limit: 5,
      limits: [5, 10]
    });
    //删除某条帖子
    table.on('tool(deletePost)', function (obj) {
      console.log(obj.data);
      layer.confirm("确认删除该条评论？", {
                icon: 3,
                btn: ['确认', '取消']
              },
              function () {
                $.ajax({
                  url: '/post/deletePostById?pid=' + obj.data.pid,
                  success: function (res) {
                    // var cacheData = table.cache['ID-table-demo'];//获取缓存
                    res === 'success' ? layer.msg("删除成功") : layer.msg("删除失败");
                    obj.del();
                    // var rowIndex = obj.tr.attr("data-index"); //获取行索引
                    // cacheData.splice(rowIndex, 1);  //②彻底移除元素，从缓存里移除这一行
                  },
                  error: function () {
                    layer.msg("删除失败，请检查网络");
                  }
                })
              },
              function () {
                layer.msg('取消成功');
              }
      )
    });

  })
</script>

</body>
</html>
